package games.platformer.behaviors;

import vooga.entities.Entity;
import vooga.behaviors.AbstractBehavior;


/**
 * Enemy Behavior
 * 
 * created 12-14
 * @author Ben Shelton
 * 
 * Enemies bob up and down - you have to avoid them
 * 
 */
public class EnemyBehavior extends AbstractBehavior
{
	int myMotionRange;
	int myVelocity;
	int myOffset;
	
	boolean myIsMovingUp;
	
    public EnemyBehavior(int motionRange, int velocity)
    {
    	myMotionRange = motionRange;
    	myIsMovingUp = true;
    	myVelocity = velocity;
    	myOffset = 0;
    }
    
    /**
     *  enemies bob up and down
     */
    public void step (Entity target)
    {
    	if(myOffset <= 0)
    		myIsMovingUp = true;
    	
    	if(myOffset >= myMotionRange)
    		myIsMovingUp = false;
    	
    	if(myIsMovingUp)
    	{
    		target.getVelocity().setYChange(-1 * myVelocity);
    		myOffset++;
    	}
    	else
    	{
    		target.getVelocity().setYChange(myVelocity);
    		myOffset--;
    	}
    }
}
